<?
if($_POST["selbox"] != ''){
	
	if($check_me_authed == "OK"){

		$today_date 			= date("d-m-Y");
		
		$srcDbHdr			      = "PCH_ORDER_HDR";
    $srcDbHdrLog	      = "LOG_PCH_ORDER_HDR";
    $srcDbDtl           = "PCH_ORDER_DTL";
    $srcDbSubDtl        = "PCH_ORDER_SUB_DTL";
    
    $UID     = unserialize($_SESSION["serUID"]);
    $userId  = $UID->getUID();

		$COracle = new oracleDb;
    $COracle->init($_SESSION["ORCL"], 
                   $_SESSION["OPASS"],
                   $_SESSION["SID"],
                   _NO_COMMENT);
    
    if ($COracle->connect()) {
			
			
			if(sizeof($_POST["selbox"]) == 0){
				
				echo "Error nothing to be delete.\n";
			}else{
				
				foreach($_POST["selbox"] as $delThisJobId){
          
          /**
      		* Fetch global header
      		* And check the status if it is valid
      		* where STATUS = _NOT_ACTIVE
      		*
      		*/
      		fetchLstDataHeader($COracle,
                             $delThisJobId,
                             $srcDbHdr,
                             $nHeader,
                             $lstHeader);
          
          if($lstHeader["STATUS"][0] == _NOT_ACTIVE){
            
            /** 
          	* Delete the previous entry
          	*
          	*/
          	dbEntDelete($COracle,
          	            $delThisJobId,
          	            $srcDbHdr);
          	            
            dbEntDelete($COracle,
          	            $delThisJobId,
          	            $srcDbDtl);
          	            
            dbEntDelete($COracle,
          	            $delThisJobId,
          	            $srcDbSubDtl);
          	            
            /**
            * Insert Log
            *
            */
            insToDbLog($COracle,
                       $today_date,
                       $delThisJobId,
                       $userId,
                       $_SERVER["REMOTE_ADDR"],
                       _DELETE_MODE,
                       $srcDbHdrLog);
            
          }else{
            
            usrDie("Error: Tx is ACTIVE/APPROVED/CANCELED");
          }
				
			  }
			
  			$COracle->commit();
  			
  			if($COracle->getStatus() == true){
  
      	  usrMsg("Delete Complete");
      	}else{
      	  
      	  usrMsg("Delete Process Interupted");
      	}
      	
      	$COracle->dc();
  			
  			//jumpTo(2,"../".$_SESSION["source_caller"]);
      }
		}else{
			
			usrDie("Error: Connection to oracle Failed");
		}
	}else{
		
		usrDie("Error: Connection to oracle Failed");
	}
}
?>